package com.code.controller;

import com.code.common.R;
import com.code.entity.Orders;
import com.code.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author admin
 */
@Slf4j
@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    private OrderService orderService;

    /**
     * 用户下单
     * @param orders
     * @return
     */
    @PostMapping("/submit")
    private R<String> submit(@RequestBody Orders orders) {
        try {
            log.info("订单数据：{}", orders);
            orderService.submit(orders);
            return R.success("下单成功");
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
